<!DOCTYPE HTML>
<html>
<head th:replace="mgr/base/head :: head('评论配置')"></head>
<body>
	<nav th:replace="mgr/base/nav :: active('config-comment')"></nav>
	<div id="page-wrapper" style="padding: 10px">
		<div class="container-fluid">
			<div class="row" style="padding: 5px">
				<div class="col-md-6 col-md-offset-3">
					<div class="tip" style="margin-top: 10px"></div>
					<form method="post" id="commentForm">
						<div class="form-group">
							<label>是否审核评论</label> <label class="radio-inline"> <input
								type="radio" name="check" value="true"
								th:attr="checked=${config.check ? 'checked' : null}">
								是
							</label> <label class="radio-inline"> <input type="radio"
								name="check" value="false"
								th:attr="checked=${config.check ? null : 'checked'}">
								否
							</label>
						</div>
						<div class="form-group">
							<label>编辑器</label> <select class="form-control"
								name="editor">
								<option th:value="${config.editor.name()}"
									selected="selected"
									th:text="'当前:'+${config.editor.name()}"></option>
								<option value="HTML">HTML</option>
								<option value="MD">MD</option>
							</select>
						</div>
						<div class="form-group">
							<label for="">每页显示数量(1~50)</label> <input
								class="form-control integer" placeholder="时间"
								th:value="${config.pageSize}"
								name="pageSize">
						</div>
						<div class="alert alert-info">在单位时间(秒)内，用户最多只能评论多少条</div>
						<div class="form-group">
							<label for="">时间(秒)(1~300)</label> <input
								class="form-control integer" placeholder="时间"
								th:value="${config.limitSec}" name="limitSec">
						</div>
						<div class="form-group">
							<label for="">允许发表评论数(1~100)</label> <input
								class="form-control integer" placeholder="时间"
								th:value="${config.limitCount}" name="limitCount">
						</div>
						<button type="button" id="update" class="btn btn-default">修改评论配置</button>
					</form>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="base/foot_source"></div>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#update").click(function() {
				var data = $("#commentForm").serializeObject();
				$.ajax({
					type : "post",
					url : basePath + "/mgr/comment/updateConfig",
					data : JSON.stringify(data),
					dataType : "json",
					contentType : 'application/json',
					success : function(data) {
						if (data.success) {
							success(data.message);
							setTimeout(function() {
								window.location.reload();
							}, 500);
						} else {
							error(data.message);
						}
					},
					complete : function() {
						$("#update").prop("disabled", false);
					}
				});
			});
		});
	</script>
</body>
</html>
